package com.watchthelan.web.schedule.event;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.mvc.SimpleFormController;

import com.watchthelan.domain.Event;
import com.watchthelan.service.schedule.event.EventManager;

public class EventFormController extends SimpleFormController {
	/** Logger for this class and subclasses */
	protected final Log logger = LogFactory.getLog(getClass());
	
	private EventManager eventManager;
	
	protected Object formBackingObject(HttpServletRequest request) throws ServletException {
		logger.info("get event");
		Event event = new Event();
		String id = request.getParameter("id");
		logger.info("id = " + id);
		if (id != null) {
			event = this.eventManager.getEventById(new Long(id));
		}
		return event;
	}


	public EventManager getEventManager() {
		return eventManager;
	}


	public void setEventManager(EventManager eventManager) {
		this.eventManager = eventManager;
	}
}
